
/**
 * 加载图片纹理，返回纹理句柄
 * @param {WebGLRenderingContext} gl 
 * @param {src} src 
 * @returns {WebGLTexture}
 */
 export function loadImage(gl, src){
    const textureHandl =gl.createTexture();
    const image=new Image();
    image.src=src;
    image.onload = function(){
        gl.bindTexture(gl.TEXTURE_2D,textureHandl);
        gl.texImage2D(gl.TEXTURE_2D,0,gl.RGBA,gl.RGBA,gl.UNSIGNED_BYTE,image);
        gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MAG_FILTER,gl.LINEAR);
        gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,gl.LINEAR);
        
        gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,gl.MIRRORED_REPEAT)
        gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_T,gl.MIRRORED_REPEAT)
        gl.bindTexture(gl.TEXTURE_2D,null);
    }
    return textureHandl;
}

